<template>
  <div class="form-single">
    <group>
      <cell 
            title="发标主题"
            :value="inviteBidData[0].InviteBidTopic"
           >
      </cell>
      <cell 
            title="答疑状态"
            :value="inviteBidData[0].Status"
           >
      </cell>
      <cell 
            title="答疑截止时间"
            :value="inviteBidData[0].EndBidTime|formatDate('YYYY-MM-DD HH:mm:ss')"
           >
      </cell>
       <cell 
            title="发标日期"
            :value="inviteBidData[0].EmitBidTime|formatDate('YYYY-MM-DD')"
           >
      </cell>
    </group>
    <group>
         <popup-picker title="提问类型"
                    :data="list"
                    v-model="inviteBidQuestionData.QuestionType"
                    placeholder="提问类型"></popup-picker>

      <x-input title="疑问标题"
               placeholder="请输入你的疑问"
               v-model="inviteBidQuestionData.QuestionTitle" required ref="input01"></x-input>

      <x-textarea title="疑问内容"
            placeholder="请简要说明你的疑问"
            :show-counter="false"
            :rows="3"
            v-model="inviteBidQuestionData.QuestionContent"></x-textarea>

    </group>
    <box gap="30px 20px 20px">
      <x-button class="btn-black"
                type="primary"
                action-type="button" style="background-color:#DC220B" @click.native='submit'>提交</x-button>
    </box>
  </div>
</template>

<script>
import { Alert, PopupPicker, Box, XButton, XTextarea, XInput, Datetime, Group, Cell } from 'vux'
import { MyInviteBidService, InviteBidQuestionService } from '../../service/Services.js'

export default {
  name: 'FormSingle',
  components: {
    Alert,
    PopupPicker,
    Box,
    XButton,
    XTextarea,
    XInput,
    Datetime,
    Group,
    Cell
  },
  data () {
    return {
      inviteBidData: {},
      inviteBidQuestionData: { QuestionType: ['其他类'], QuestionTitle: '', QuestionContent: '' },
      list: [['技术类', '商务类', '其他类']]
    }
  },
  methods: {
    loadData () {
      this.$vux.loading.show({
        text: '加载中...'
      })
      let providerGUID = this.$store.getters.getUserInfo.ProviderGUID
      let cgPlanGUID = this.$route.query.CgPlanGUID
      let inviteBidGUID = this.$route.query.InviteBidGUID
      this.inviteBidQuestionData.ProviderGUID = providerGUID
      this.inviteBidQuestionData.CgPlanGUID = cgPlanGUID
      this.inviteBidQuestionData.InviteBidGUID = inviteBidGUID
      MyInviteBidService.getInviteBid(inviteBidGUID).then((res) => {
        this.$vux.loading.hide()
        this.inviteBidData = res.Data
      })
    },
    submit () {
      if (!this.inviteBidQuestionData.QuestionTitle || !this.inviteBidQuestionData.QuestionContent) {
        this.$vux.alert.show({
          title: '提示',
          content: '请输入疑问标题和疑问内容'
        })
        return
      } else {
        this.$vux.loading.show({
          text: '提交中...'
        })
        InviteBidQuestionService.submitInviteBidQuestion(this.inviteBidQuestionData).then((res) => {
          this.$vux.loading.hide()
          if (!res.Result) {
            this.$vux.toast.show({
              text: res.ErrorMessage,
              type: 'cancel',
              width: '180px'
            })
          } else {
            this.$router.push({path: '/demos/invite-bid-question',
              query: {InviteBidForenoticeGUID: this.$route.query.InviteBidForenoticeGUID,
                InviteBidGUID: this.$route.query.InviteBidGUID,
                CgPlanGUID: this.$route.query.CgPlanGUID}
            })
          }
        })
      }
    }
  },
  created () {
    this.loadData()
  }
}
</script>

<style scoped>
.form-info{
  width: 25px;
}

.icon-information {
  color: #09BB07;
  font-size: 18px;
}

.btn-black {
  background-color: #333;
}

.btn-black:active {
    color: #fff;
    background-color: #555;
}
</style>
